//权限管理
import router from './router/index'
import store from './store/index'


const whiteList = ['/Login']


router.beforeEach((to, from, next) => {
    const token = store.state.token
    if (token) {
        if (!whiteList.includes(to.path)) {
            next() //如果在白名单中 直接放行
        } else {
            //如果登录了留在原地
            next(false)
        }
    } else {
        if (!whiteList.includes(to.path)) {
            next(`/Login?from=${to.path}`)  //登录之后调回上个页面
        } else {
            next()
        }
    }
})